package testservice;

import com.domain.bean.sys.SysMenu;
import com.domain.bean.sys.SysRole;
import com.pachong.service.SysRoleService;
import com.wy.dao.sys.SysMenuDAO;
import com.wy.dao.sys.SysRoleDAO;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Author : wangyu
 * Date: 2018-03-01
 * Time: 14:57
 */
//TODO 重点注意test测试用例中的事务会回滚
public class SysMenuTest extends BaseTest {
    @Autowired
    private SysRoleService roleService;
    @Autowired
    private SysRoleDAO sysRoleDAO;
    @Autowired
    private SysMenuDAO sysMenuDAO;

    @Test
    public void test1(){
        SysRole aaa = new SysRole();
        System.err.println("---------------");
        aaa.setRoleName("testSave");
        roleService.deleteByPrimaryKey("2c90889c61e07e510161e07e7fab0000");
        System.err.println("---------------");
        System.err.println("1");
    }

    @Test
    public void test2(){
        SysRole aaa = new SysRole();
        SysMenu menu = new SysMenu();
        aaa.setId("2619a672e53811e7b983201a068c6482");
        menu.setId("0e6c8d4cf09511e78a57201a068c6482----");
        aaa.getMenus().add(menu);
        Example<SysRole> example = Example.of(aaa);
        boolean exists = sysRoleDAO.exists(example);
        System.err.println("是否存在："+exists);
    }

    @Test
    public void test3(){
        SysRole role = new SysRole();
        SysMenu menu = new SysMenu();
        role.setId("2c90889c61e0c7230161e0c742930000");
        role.setRoleName("test2");
        menu.setId("2c90889c61e0c22a0161e0c248d50000");
        menu.setName("test2");
        role.getMenus().add(menu);
        sysRoleDAO.save(role);
        System.err.println("是否存在：");
    }


    @Test
    public void test4(){
        SysMenu menu = new SysMenu();
        menu.setName("teasdlajsdjasdjasjdj------------");
        sysMenuDAO.save(menu);
        System.err.println("是否存在：");
    }

    @Test
    public void test5(){
        SysRole role = new SysRole();
        role.setRoleName("J角色测试名称11111");
        SysRole save = sysRoleDAO.save(role);
        System.err.println("是否存在：");
    }

}
